<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button id="begin">开始</button>
    <button id="inter">交互</button>
</body>
<script>
    var begin = document.getElementById('begin')
    var inter = document.getElementById('inter')

    function delay(duration) {
        var start = new Date()
        while (Date.now() - start < duration) { }
    }

    function addDelay() {
        console.log('添加延时队列')
        setTimeout(() => {
            console.log('延时队列执行')
        }, 100);
        delay(2000)
    }

    function addInter() {
        console.log('添加交互队列')
        inter.onclick = () => {
            console.log('交互执行')
        }
        delay(2000)
    }

    begin.onclick = () => {
        this.addDelay()
        this.addInter()
        console.log('=============')
    }
</script>

</html>